package postjnlv2_param.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;

import postjnlv2_param.controller.PostJNLController;


public class PostJNL_Panel_View extends JFrame{	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public JTable tableau;
    public DefaultTableModel tableModel;
	
	private Font font = new Font("Comic Sans MS", Font.BOLD, 12);
	private Font fontBouton = new Font("Broadway", Font.BOLD, 12);
	private JPanel postJnl_Panel, boutonPanel;
	private JPanel jnlPanel;
	public JButton btValider;	
	public JLabel lbJnlEnDt,lbJnlRefNo,lbIdRun;
	public JTextField txtJnlEnDtLb,txtJnlEnDtResult, txtJnlEntete1,txtJnlEntete2;
	public JTextField txtJnlType1, txtJnlType2,txtJnlRefNo1 ,txtJnlRefNo2,txtIdRunLb,txtIdRunResult ;
	public Rapport_Panel_View rapport_Panel_View;	
    
	public JPanel postJNL_Panel_View(Rapport_Panel_View rapport_Panel_View){
		this.rapport_Panel_View=rapport_Panel_View;
	    		
		
		//Parametrage Facture Marque Blanche
		postJnl_Panel= new JPanel();
		postJnl_Panel.setPreferredSize(new Dimension(400,400));
		Border titledBorderTrafic = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.getHSBColor(93/360F, 0.57F, 0.60F)), "Traitement postJNLv2 :", TitledBorder.LEFT, TitledBorder.TOP, font, Color.getHSBColor(93/255F, 0.57F, 0.60F));
		postJnl_Panel.setBorder(BorderFactory.createTitledBorder(titledBorderTrafic));
		postJnl_Panel.setLayout(new BoxLayout(postJnl_Panel,BoxLayout.Y_AXIS));						
		
		//Detail facture panel
		jnlPanel =new JPanel();
		jnlPanel.setLayout(new GridBagLayout());
		
		//MAX(JNL_END_DT)
        GridBagConstraints gridBagConstraintsLbEndDt = new GridBagConstraints();
        lbJnlEnDt = new JLabel("JNL_END_DT : ");
        gridBagConstraintsLbEndDt.gridx = 0;
        gridBagConstraintsLbEndDt.gridy = 0;
        gridBagConstraintsLbEndDt.insets = new Insets(0,0,0,20);
        gridBagConstraintsLbEndDt.anchor = gridBagConstraintsLbEndDt.WEST;
        jnlPanel.add(lbJnlEnDt, gridBagConstraintsLbEndDt);
      
        GridBagConstraints gridBagConstraintsTxtEndDtLB = new GridBagConstraints();
        txtJnlEnDtLb = new JTextField(12);
        txtJnlEnDtLb.setText("MAX(JNL_END_DT)");
        txtJnlEnDtLb.setEditable(false);       
        gridBagConstraintsTxtEndDtLB.gridx = 1;
        gridBagConstraintsTxtEndDtLB.gridy = 0;
        gridBagConstraintsTxtEndDtLB.insets = new Insets(0,0,0,20);
        gridBagConstraintsTxtEndDtLB.anchor = gridBagConstraintsTxtEndDtLB.WEST;
        jnlPanel.add(txtJnlEnDtLb, gridBagConstraintsTxtEndDtLB);
        
        GridBagConstraints gridBagConstraintsTxtEndDtResult = new GridBagConstraints();
        txtJnlEnDtResult = new JTextField(12);
        txtJnlEnDtResult.setEditable(false);
        txtJnlEnDtResult.setBackground(Color.white);
        gridBagConstraintsTxtEndDtResult.gridx = 1;
        gridBagConstraintsTxtEndDtResult.gridy = 1;
        gridBagConstraintsTxtEndDtResult.insets = new Insets(0,0,20,20);
        gridBagConstraintsTxtEndDtResult.anchor = gridBagConstraintsTxtEndDtResult.WEST;
        jnlPanel.add(txtJnlEnDtResult, gridBagConstraintsTxtEndDtResult);
        
        
        
        //MAX(JNL_REF_NO)
        GridBagConstraints gridBagConstraintsRefno = new GridBagConstraints();
        lbJnlRefNo = new JLabel("JNL_REF_NO : ");
        gridBagConstraintsRefno.gridx = 0;
        gridBagConstraintsRefno.gridy = 2;
        gridBagConstraintsRefno.insets = new Insets(0,0,0,20);
        gridBagConstraintsRefno.anchor = gridBagConstraintsRefno.WEST;
        jnlPanel.add(lbJnlRefNo, gridBagConstraintsRefno);
        
        //ENTETE
        GridBagConstraints gridBagConstraintsEntete1 = new GridBagConstraints();
        txtJnlEntete1 = new JTextField(6);
        txtJnlEntete1.setText("JNL_TYPE");
        txtJnlEntete1.setEditable(false);
        gridBagConstraintsEntete1.gridx = 1;
        gridBagConstraintsEntete1.gridy = 2;
        gridBagConstraintsEntete1.insets = new Insets(0,0,0,20);
        gridBagConstraintsEntete1.anchor = gridBagConstraintsEntete1.WEST;
        jnlPanel.add(txtJnlEntete1, gridBagConstraintsEntete1);                
        
        GridBagConstraints gridBagConstraintsEntete2 = new GridBagConstraints();
        txtJnlEntete2 = new JTextField(11);
        txtJnlEntete2.setText("MAX(JNL_REF_NO)");
        txtJnlEntete2.setEditable(false);
        gridBagConstraintsEntete2.gridx = 2;
        gridBagConstraintsEntete2.gridy = 2;
        gridBagConstraintsEntete2.insets = new Insets(0,-87,0,20);
        gridBagConstraintsEntete2.anchor = gridBagConstraintsEntete2.WEST;
        jnlPanel.add(txtJnlEntete2, gridBagConstraintsEntete2);
        
        //LIGNE 1
        GridBagConstraints gridBagConstraintsTyp1 = new GridBagConstraints();
        txtJnlType1 = new JTextField(6);
        txtJnlType1.setText("1");
        txtJnlType1.setEditable(false);
        txtJnlType1.setBackground(Color.white);
        gridBagConstraintsTyp1.gridx = 1;
        gridBagConstraintsTyp1.gridy = 3;
        gridBagConstraintsTyp1.insets = new Insets(0,0,0,20);
        gridBagConstraintsTyp1.anchor = gridBagConstraintsTyp1.WEST;
        jnlPanel.add(txtJnlType1, gridBagConstraintsTyp1);                
        
        GridBagConstraints gridBagConstraintsTyp2 = new GridBagConstraints();
        txtJnlRefNo1 = new JTextField(11);
        txtJnlRefNo1.setEditable(false);
        txtJnlRefNo1.setBackground(Color.white);
        gridBagConstraintsTyp2.gridx = 2;
        gridBagConstraintsTyp2.gridy = 3;
        gridBagConstraintsTyp2.insets = new Insets(0,-87,0,20);
        gridBagConstraintsTyp2.anchor = gridBagConstraintsTyp2.WEST;
        jnlPanel.add(txtJnlRefNo1, gridBagConstraintsTyp2);
        
        //LIGNE 2
        GridBagConstraints gridBagConstraintsTxtRefTyp1 = new GridBagConstraints();
        txtJnlType2 = new JTextField(6);
        txtJnlType2.setText("2");
        txtJnlType2.setEditable(false);
        txtJnlType2.setBackground(Color.white);
        gridBagConstraintsTxtRefTyp1.gridx = 1;
        gridBagConstraintsTxtRefTyp1.gridy = 4;
        gridBagConstraintsTxtRefTyp1.insets = new Insets(0,0,20,20);
        gridBagConstraintsTxtRefTyp1.anchor = gridBagConstraintsTxtRefTyp1.WEST;
        jnlPanel.add(txtJnlType2, gridBagConstraintsTxtRefTyp1);                
        
        GridBagConstraints gridBagConstraintsTxtRefTyp2 = new GridBagConstraints();
        txtJnlRefNo2 = new JTextField(11);
        txtJnlRefNo2.setEditable(false);
        txtJnlRefNo2.setBackground(Color.white);
        gridBagConstraintsTxtRefTyp2.gridx = 2;
        gridBagConstraintsTxtRefTyp2.gridy = 4;
        gridBagConstraintsTxtRefTyp2.insets = new Insets(0,-87,20,20);
        gridBagConstraintsTxtRefTyp2.anchor = gridBagConstraintsTxtRefTyp2.WEST;
        jnlPanel.add(txtJnlRefNo2, gridBagConstraintsTxtRefTyp2);
        
        //ID_RUN
        GridBagConstraints gridBagConstraintslbIdRun = new GridBagConstraints();
        lbIdRun = new JLabel("ID_RUN : ");
        gridBagConstraintslbIdRun.gridx = 0;
        gridBagConstraintslbIdRun.gridy = 5;
        gridBagConstraintslbIdRun.insets = new Insets(0,0,0,20);
        gridBagConstraintslbIdRun.anchor = gridBagConstraintslbIdRun.EAST;
        jnlPanel.add(lbIdRun, gridBagConstraintslbIdRun);
        
        GridBagConstraints gridBagConstraintsIdRunLb = new GridBagConstraints();
        txtIdRunLb = new JTextField(12);
        txtIdRunLb.setText("T_ID_RUN");
        txtIdRunLb.setEditable(false);
        gridBagConstraintsIdRunLb.gridx = 1;
        gridBagConstraintsIdRunLb.gridy = 5;
        gridBagConstraintsIdRunLb.insets = new Insets(0,0,0,20);
        gridBagConstraintsIdRunLb.anchor = gridBagConstraintsIdRunLb.WEST;
        jnlPanel.add(txtIdRunLb, gridBagConstraintsIdRunLb);
        
        GridBagConstraints gridBagConstraintsIdRunResult = new GridBagConstraints();
        txtIdRunResult = new JTextField(12);
        txtIdRunResult.setEditable(false);
        txtIdRunResult.setBackground(Color.white);
        gridBagConstraintsIdRunResult.gridx = 1;
        gridBagConstraintsIdRunResult.gridy = 6;
        gridBagConstraintsIdRunResult.insets = new Insets(0,0,0,20);
        gridBagConstraintsIdRunResult.anchor = gridBagConstraintsIdRunResult.WEST;
        jnlPanel.add(txtIdRunResult, gridBagConstraintsIdRunResult);
        
        postJnl_Panel.add(jnlPanel);
       
              
        //bouton Panel
		boutonPanel = new JPanel();
		boutonPanel.setLayout(new GridBagLayout());
       	
        //libelle boutton
        GridBagConstraints gridBagConstraintsbtValider = new GridBagConstraints();
        btValider = new JButton("Lancer Traitement 'PostJnl'");
        btValider.setPreferredSize(new Dimension(250,21));
        btValider.setBackground(Color.black);
        btValider.setFont(fontBouton);
        btValider.setForeground(Color.getHSBColor(39,233,255));
        gridBagConstraintsbtValider.gridx = 1;
        gridBagConstraintsbtValider.gridy = 2;
        gridBagConstraintsbtValider.insets = new Insets(10, 0, 10, 50);
        gridBagConstraintsbtValider.anchor = gridBagConstraintsbtValider.WEST;
        boutonPanel.add(btValider, gridBagConstraintsbtValider);
            
        
        postJnl_Panel.add(boutonPanel); 
        btValider.addActionListener(new PostJNLController(this,rapport_Panel_View));
	    return postJnl_Panel;
	  
    }
}
